<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>权限管理</title>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/x-layui.js" charset="utf-8"></script>
</head>
<body>

<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>权限管理</cite></a>
              <a><cite>权限列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body">

    <xblock>
        <button class="layui-btn" onclick="add('权限添加',
                '${pageContext.request.contextPath}/permission/addUi','1000','600')">
            <i class="layui-icon">&#xe608;</i>添加
        </button>
        <span class="x-right" style="line-height:40px">共有数据：
            <span class="layui-badge">${permissions.size()}</span> 条</span></xblock>

    <table class="layui-table">
        <thead>
        <tr>
            <th>序号</th>
            <th>权限名称</th>
            <th>权限规则</th>
            <th>权限等级</th>
            <th>创建时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>

        <tbody>
        <c:forEach items="${permissions}" var="permission" varStatus="status">
            <tr>
                <td>${status.index + 1}</td>
                <td>${permission.name}</td>
                <td>${permission.rule}</td>
                <td>${permission.level}</td>
                <td>
                    <fmt:formatDate pattern="yyyy/MM/dd HH:mm:ss" value="${permission.createTime}"/>
                </td>
                <td>
                    <c:if test="${permission.state}">禁用</c:if>
                    <c:if test="${!permission.state}">可用</c:if>
                </td>
                <td class="td-manage">
                    <a title="编辑" href="javascript:;"
                       onclick="edit('编辑权限','${pageContext.request.contextPath}/permission/editUi','${permission.id}','1000','600')"
                       class="ml-5" style="text-decoration:none">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除"
                       href="${pageContext.request.contextPath}/permission/delete?id=${permission.id}" style="text-decoration:none">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
        </c:forEach>


        </tbody>
    </table>

    <div id="page"></div>
</div>

<script>
    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
    });

    /*添加*/
    function add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    //编辑
    function edit (title,url,id,w,h) {
        url = url+"?id="+id;
        x_admin_show(title,url,w,h);
    }


</script>

</body>
</html>